home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / source.exe / POSIX / SH / STD / STDC / STRSPN.C < prev    next >
C/C++ Source or Header  |  1992-07-13  |  483b  |  28 lines

  1. #include <string.h>
  2.  
  3. /*
  4.  * strspn - find length of initial segment of s consisting entirely
  5.  * of characters from accept
  6.  */
  7.  
  8. size_t
  9. strspn(s, accept)
  10. Const char *s;
  11. Const char *accept;
  12. {
  13.     register Const char *sscan;
  14.     register Const char *ascan;
  15.     register size_t count;
  16.  
  17.     count = 0;
  18.     for (sscan = s; *sscan != '\0'; sscan++) {
  19.         for (ascan = accept; *ascan != '\0'; ascan++)
  20.             if (*sscan == *ascan)
  21.                 break;
  22.         if (*ascan == '\0')
  23.             return(count);
  24.         count++;
  25.     }
  26.     return(count);
  27. }
  28.